package com.ruoyi.recycle.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.recycle.domain.RecycleCommodity;
import com.ruoyi.recycle.mapper.RecycleCommodityMapper;
import com.ruoyi.recycle.service.IRecycleCommodityService;
import com.ruoyi.recycle.vo.RecycleCategoryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 回收商品Service业务层处理
 *
 * @author ruoyi
 * @date 2022-05-22
 */
@Service
public class RecycleCommodityServiceImpl extends ServiceImpl<RecycleCommodityMapper, RecycleCommodity> implements IRecycleCommodityService {
    @Autowired
    private RecycleCommodityMapper recycleCommodityMapper;

    /**
     * 查询回收商品
     *
     * @param id 回收商品主键
     * @return 回收商品
     */
    @Override
    public RecycleCommodity selectRecycleCommodityById(Long id) {
        return recycleCommodityMapper.selectRecycleCommodityById(id);
    }

    /**
     * 查询回收商品列表
     *
     * @param recycleCommodity 回收商品
     * @return 回收商品
     */
    @Override
    public List<RecycleCommodity> selectRecycleCommodityList(RecycleCommodity recycleCommodity) {
        return recycleCommodityMapper.selectRecycleCommodityList(recycleCommodity);
    }

    /**
     * 新增回收商品
     *
     * @param recycleCommodity 回收商品
     * @return 结果
     */
    @Override
    public int insertRecycleCommodity(RecycleCommodity recycleCommodity) {
        return recycleCommodityMapper.insertRecycleCommodity(recycleCommodity);
    }

    /**
     * 修改回收商品
     *
     * @param recycleCommodity 回收商品
     * @return 结果
     */
    @Override
    public int updateRecycleCommodity(RecycleCommodity recycleCommodity) {
        return recycleCommodityMapper.updateRecycleCommodity(recycleCommodity);
    }

    /**
     * 批量删除回收商品
     *
     * @param ids 需要删除的回收商品主键
     * @return 结果
     */
    @Override
    public int deleteRecycleCommodityByIds(Long[] ids) {
        return recycleCommodityMapper.deleteRecycleCommodityByIds(ids);
    }

    /**
     * 删除回收商品信息
     *
     * @param id 回收商品主键
     * @return 结果
     */
    @Override
    public int deleteRecycleCommodityById(Long id) {
        return recycleCommodityMapper.deleteRecycleCommodityById(id);
    }

    @Override
    public List<RecycleCategoryVO.CategoryVO> sumWeightByType(LambdaQueryWrapper<RecycleCommodity> queryWrapper) {
        return getBaseMapper().sumWeightByType(queryWrapper);
    }
}
